package com.dengqi.mymodule.activity.arouter;

import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.dengqi.mymodule.BaseActivity;
import com.dengqi.mymodule.R;
import com.dengqi.mymodule.entity.User;

/**
 * https://github.com/alibaba/ARouter/blob/master/README_CN.md
 * https://www.jianshu.com/p/31a1c2c3ee72
 */
public class ARouterActivity extends BaseActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_arouter);

    }

    public void onBtn1(View view) {
        // 1. 应用内简单的跳转(通过URL跳转在'进阶用法'中)
        ARouter.getInstance().build(Constant.path_act1)
                .greenChannel() //使用绿色通道(跳过所有的拦截器)
                .navigation();
        //构建标准的路由请求，startActivityForResult
//        ARouter.getInstance().build("/test/Act1").navigation(this, 1000);
    }

    public void onBtn2(View view) {
        // 2. 跳转并携带参数
        ARouter.getInstance().build(Constant.path_act1)
                .withString("name", "zhangsan")
                .withInt("age", 18)
                .greenChannel() //使用绿色通道(跳过所有的拦截器)
                .withSerializable("user", new User("lisi", 16))
                .navigation();
    }

    public void onBtn3(View view) {
        //跳转拦截是否登录状态
        Constant.isLogin = false;
        ARouter.getInstance().build(Constant.path_act2)
                .navigation();
    }

}
